Repository navigation
Build with Ninja, link with mold, and run the tests once (~15% faster) - #115
Open
exercism-agent[bot] wants to merge 1 commit into
Open
exercism-agent[bot] wants to merge 1 commit into
exercism-agent[bot] wants to merge 1 commit into
Conversation
Co-authored-by: iHiD <286476+iHiD@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello 🙂 I'm working with Claude to try and get our tooling faster.
This PR makes this project around 15% faster. I've run it in production to benchmark things in the real world against the most recent few hundred solutions, so I'm confident that it works robustly. However, I've not written the code. I have tried my hardest to get Claude to write sensible messages and comments that explain stuff, but I'd ask for your patience in the fact I'm sending AI code to you. Everything below here is from your friendly neighbourhood LLM...
This PR follows @ahans's suggestion on #114: build with Ninja and link with mold, and leave out the precompiled header. It also runs the tests once. That PR stays a draft.
What changed
Most of a run goes on compiling the solution and the test file. make compiles the two files one after the other. Ninja compiles them at the same time, so the build takes about as long as the slower of the two files.
-G Ninjaand builds withninja. This change saves about 0.3 s from the median run.-DCMAKE_LINKER_TYPE=MOLD, as suggested in that review. mold links faster than GNU ld because it uses all cores. This change saves about 0.1 s.run.shthen ran it again to write the XML report. The runner now builds only the${slug}target, so the tests run once. This saves little on the median, because most tests are fast. It cuts the slowest runs the most.If Ninja or mold is installed,
run.shuses it. The browser runner has neither, so it keeps building with make (nowmake "${slug}") and linking with the default linker.Ninja prints the compiler's output on stdout, after a
FAILED:line and the full compiler command.run.shremoves those lines and Ninja's closingninja: build stoppedline, so the message keeps the compiler's own output. If a second file also fails,run.shkeeps only the first one's errors, because make stopped at the first failure.While Catch2 writes the XML report, it holds back the tests' own output. Before, a crashing solution's message held that output, because the build had already run the tests with the console reporter. Now, if the parser reports an error and the test executable exists,
run.shruns the tests again with the console reporter and adds their error output to the message. This happens for solutions that crash or exit early.The image grows from 584 MB to 609 MB. mold accounts for almost all of the growth.
Messages students will see change
All 101 example solutions give byte-identical
results.jsonfiles. These error messages change:make[N]: *** [...] Error Nlines at the end are gone.In file included from bob.cpp:5), where before they came from the test file (In file included from bob_test.cpp:1). The errors themselves are the same.mold: error: undefined symbol: ...followed by>>> referenced by ...lines), in place of GNU ld'sundefined reference to ...lines.Segmentation fault (core dumped)orAborted (core dumped).exit()in a solution. If the tests exit early, the message now saysThe tests exited early with status 3.(with the actual status), in place of make'sError 3lines.The Catch2 headers in the track
This PR doesn't change the track. To measure the header change you suggested, I switched four exercises' tests from
catch_all.hpptocatch_test_macros.hpp(plus the floating-point matchers header for space-age). The results stayed the same, and each run was about 0.9s to 1.0s faster with a cold cache, with or without this PR:This has been tested in production, and has reduced the median run from 3.4s to 2.9s.
🤖 Generated with Claude Code